home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #11
/
Amiga Plus CD - 2004 - No. 11.iso
/
AmiSoft
/
Misc
/
emu
/
p-interp.lha
/
p-interp-0.5
/
native6502.c
< prev
next >
Wrap
C/C++ Source or Header
|
2001-06-10
|
17KB
|
442 lines
/*
P-Code interpreter (to run the apple pascal system)
Copyright (C) 2000 Mario Klebsch
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Log: native6502.c,v $
Revision 1.5 2001/06/10 20:40:04 mario
Long integers mit BCD-Arithmetic implementiert, Divisionsroutine fehlt noch.
Revision 1.4 2001/06/06 23:14:19 mario
Turtlegraphics wird jetzt mit einem #define aktiviert
Revision 1.3 2001/05/26 15:13:29 mario
Diverse kleine Fehler behoben, fehlende #includes, Labels ohne Statement
dahinter, ...
Revision 1.2 2001/05/20 13:12:02 mario
CVS-Idents und Logs eingefügt
*/
#ident "$Id: native6502.c,v 1.5 2001/06/10 20:40:04 mario Exp $";
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "psystem.h"
#include "pcode.h"
#include "Memory.h"
#include "Array.h"
#include "Term.h"
static void IdSearch(word EntryPoint)
{
word BufPtr = Pop();
word Arg2Ptr = Pop();
CspIdSearch(BufPtr, Arg2Ptr);
}
static byte IdSearchSig[]=
{ 0x68, 0x85, 0x7e, 0x68, 0x85, 0x7f, 0x68, 0xa8, 0x68, 0xaa,
0x68, 0x85, 0x94, 0x68, 0x85, 0x95, 0x98, 0xa0, 0x00, 0x18,
0x71, 0x94, 0x85, 0x96, 0x8a, 0xc8, 0x71, 0x94, 0x85, 0x97,
0xa9, 0x20, 0xa2, 0x07, 0x95, 0x88, 0xca, 0xd0, 0xfb, 0x88,
0xb1, 0x96, 0xc9, 0x61, 0x90, 0x07, 0xc9, 0x7b, 0xb0, 0x03 };
static void TreeSearch(word EntryPoint)
{
word TokenBuf;
word ResultPtr;
word NodePtr;
Pop(); Pop();
TokenBuf = Pop();
ResultPtr = Pop();
NodePtr = Pop(); /* initialize with root node addr */
Push(CspTreeSearch(TokenBuf, ResultPtr, NodePtr));
}
static void Randomize(word EntryPoint)
{
srand(time(0L));
}
static byte RandomizeSig1[]=
{ 0xad, 0x13, 0xbf, 0x8d, 0x3f, 0x02, 0x8d, 0x40,
0x02, 0xad, 0x14, 0xbf, 0x8d, 0x41, 0x02, 0x8d,
0x42, 0x02, 0x0d, 0x3f, 0x02, 0xd0, 0x05, 0xa9,
0x55, 0x8d, 0x42, 0x02, 0x60, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x1d, 0x00, 0x19, 0x00,
0x18, 0x00, 0x17, 0x00, 0x12, 0x00, 0x06, 0x00,
0x00, 0x00, 0x32, 0x00 };
static byte RandomizeSig2[]=
{ 0xad, 0x13, 0xbf, 0x8d, 0x25, 0x02, 0x8d, 0x26,
0x02, 0xad, 0x14, 0xbf, 0x8d, 0x27, 0x02, 0x8d,
0x28, 0x02, 0x0d, 0x25, 0x02, 0xd0, 0x05, 0xa9,
0x55, 0x8d, 0x28, 0x02, 0x60, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x1d, 0x00, 0x19, 0x00,
0x18, 0x00, 0x17, 0x00, 0x12, 0x00, 0x06, 0x00,
0x00, 0x00, 0x32, 0x00 };
static void Keypress(word EntryPoint)
{
Pop();
Pop();
Push(TermStat());
}
static byte KeypressSig[]=
{ 0x68, 0x85, 0x00, 0x68, 0x85, 0x01, 0x68, 0x68,
0x68, 0x68, 0xa9, 0x00, 0x48, 0xad, 0x21, 0xbf,
0xd0, 0x06, 0x20, 0x5c, 0xff, 0x4c, 0x1b, 0x00,
0x20, 0x0a, 0xbf, 0xad, 0x18, 0xbf, 0xcd, 0x19,
0xbf, 0xf0, 0x04, 0xa9, 0x01, 0xd0, 0x02, 0xa9,
0x00, 0x48, 0xa5, 0x01, 0x48, 0xa5, 0x00, 0x48,
0x60, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x00 };
static void Random(word EntryPoint)
{
Pop();
Pop();
Push(rand()&0x7fff);
}
static byte RandomSig[]=
{ 0x68, 0x85, 0x00, 0x68, 0x85, 0x01, 0x68, 0x68,
0x68, 0x68, 0xa0, 0x07, 0x0e, 0x39, 0x00, 0x08,
0x2e, 0x3a, 0x00, 0x2e, 0x3b, 0x00, 0x2e, 0x3c,
0x00, 0x30, 0x05, 0x28, 0x10, 0x08, 0x30, 0x03,
0x28, 0x30, 0x03, 0xee, 0x39, 0x00, 0x88, 0xd0,
0xe3, 0xad, 0x39, 0x00, 0x4a, 0x48, 0xad, 0x3b,
0x00, 0x48, 0xa5, 0x01, 0x48, 0xa5, 0x00, 0x48,
0x60, 0x5a, 0xb2, 0xf6, 0x93, 0x00, 0x00, 0x00,
0x33, 0x00, 0x31, 0x00, 0x30, 0x00, 0x2f, 0x00,
0x24, 0x00, 0x20, 0x00, 0x1d, 0x00, 0x07, 0x00,
0x00, 0x00, 0x00, 0x00, 0x54, 0x00 };
static byte TreeSearchSig[]=
{ 0x68, 0x85, 0x84, 0x68, 0x85, 0x85, 0x68, 0x68, 0x68, 0x68,
0x68, 0x85, 0x82, 0x68, 0x85, 0x83, 0x68, 0x85, 0x7e, 0x68,
0x85, 0x7f, 0x68, 0x85, 0x80, 0x68, 0x85, 0x81, 0xa2, 0x08,
0xa0, 0xff, 0xca, 0x30, 0x37, 0xc8, 0xb1, 0x82, 0xd1, 0x80,
0xf0, 0xf6, 0x30, 0x17, 0xa0, 0x08, 0xb1, 0x80, 0xaa, 0xc8,
0xb1, 0x80, 0xc9, 0x00, 0xd0, 0x04, 0xe0, 0x00, 0xf0, 0x2c,
0x86, 0x80, 0x85, 0x81, 0x4c, 0x1c };
#ifdef TURTLEGRAPHICS
extern void TurtleGraphics(word EntryPoint);
static byte TurtleSig[16]="TURTLEGRAPHICS::";
#endif
extern void LongInt(word EntryPoint);
static byte LongIntSig[]=
{ 0x68, 0x85, 0x76, 0x68, 0x85, 0x77, 0x68, 0xaa,
0x68, 0xbd, 0x16, 0x00, 0x85, 0x78, 0xbd, 0x17,
0x00, 0x85, 0x79, 0x6c, 0x78, 0x00, 0xa2, 0x00,
0x4d, 0x02, 0x7a, 0x02, 0xd1, 0x00, 0xad, 0x02,
0xc3, 0x03, 0x03, 0x06, 0x1f, 0x05, 0xe0, 0x00,
0x03, 0x05, 0x7c, 0x05, 0xe6, 0x76, 0xd0, 0x02,
0xe6, 0x77, 0x6c, 0x76, 0x00, 0xa9, 0x05, 0x6c,
0x00, 0x00, 0xa9, 0x0d, 0x6c, 0x00, 0x00, 0xa9,
0x06, 0x6c, 0x00, 0x00, 0x68, 0x85, 0x7a, 0x68,
0x85, 0x7b, 0x68, 0x85, 0x81, 0xc6, 0x81, 0x06,
0x81, 0x68, 0x68, 0x85, 0x83, 0x68, 0xba, 0xe8,
0xbd, 0x00, 0x01, 0xd0, 0x05, 0xe8, 0xc6, 0x81,
0xd0, 0xf6, 0x86, 0x7d, 0x8a, 0x18, 0x65, 0x81,
0xaa, 0xca, 0x86, 0x7f, 0xe8, 0xbd, 0x00, 0x01,
0x85, 0x80, 0xc6, 0x80, 0x06, 0x80, 0xe8, 0xe8,
0xbd, 0x00, 0x01, 0x85, 0x82, 0xe8, 0xe8, 0xbd,
0x00, 0x01, 0xd0, 0x05, 0xe8, 0xc6, 0x80, 0xd0,
0xf6, 0x86, 0x7c, 0xca, 0x8a, 0x18, 0x65, 0x80,
0x85, 0x7e, 0xa5, 0x80, 0x38, 0xe5, 0x81, 0x85,
0x84, 0xe6, 0x7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0x05, 0xea, 0xea,
0xf0, 0x05, 0xea, 0xea, 0xa6, 0x7e, 0x9a, 0xa9,
0x00, 0x48, 0x48, 0x48, 0x48, 0x48, 0xa9, 0x02,
0x48, 0x4c, 0x2c, 0x00, 0xa5, 0x81, 0x85, 0x85,
0xa4, 0x7f, 0xa6, 0x7e, 0xb9, 0x00, 0x01, 0x9d,
0x00, 0x01, 0xca, 0x88, 0xc6, 0x85, 0xd0, 0xf4,
0x9a, 0x46, 0x81, 0x90, 0x05, 0xa9, 0x00, 0x48,
0xe6, 0x81, 0x48, 0xa5, 0x83, 0x48, 0x48, 0xe6,
0x81, 0xa5, 0x81, 0x48, 0x4c, 0x2c, 0x00, 0xa4,
0x80, 0xa6, 0x84, 0x30, 0x06, 0xa4, 0x81, 0xa5,
0x80, 0x85, 0x81, 0x84, 0x85, 0xa4, 0x7f, 0xa6,
0x7e, 0x18, 0xf8, 0xb9, 0x00, 0x01, 0x7d, 0x00,
0x01, 0x9d, 0x00, 0x01, 0xca, 0x88, 0xc6, 0x85,
0xd0, 0xf1, 0xa5, 0x84, 0xf0, 0x18, 0x30, 0x08,
0x49, 0xff, 0x85, 0x84, 0xe6, 0x84, 0x8a, 0xa8,
0xb9, 0x00, 0x01, 0x69, 0x00, 0x9d, 0x00, 0x01,
0xca, 0x88, 0xe6, 0x84, 0xd0, 0xf2, 0xd8, 0x9a,
0x90, 0x05, 0xa9, 0x01, 0x48, 0xe6, 0x81, 0xa5,
0x82, 0x85, 0x83, 0x4c, 0x81, 0x01, 0xa5, 0x80,
0xc5, 0x81, 0xd0, 0x17, 0x85, 0x85, 0xa6, 0x7c,
0xa4, 0x7d, 0xbd, 0x00, 0x01, 0xd9, 0x00, 0x01,
0xd0, 0x09, 0xe8, 0xc8, 0xc6, 0x85, 0xd0, 0xf2,
0x4c, 0x5c, 0x01, 0xb0, 0x0a, 0xa6, 0x7e, 0xa4,
0x7f, 0xa5, 0x80, 0x85, 0x85, 0xd0, 0x08, 0xa6,
0x7f, 0xa4, 0x7e, 0xa5, 0x81, 0x85, 0x85, 0x38,
0xf8, 0xb9, 0x00, 0x01, 0xfd, 0x00, 0x01, 0x99,
0x00, 0x01, 0xca, 0x88, 0xc6, 0x85, 0xd0, 0xf1,
0xb0, 0x0b, 0xb9, 0x00, 0x01, 0xe9, 0x00, 0x99,
0x00, 0x01, 0x88, 0x90, 0xf5, 0xd8, 0xc4, 0x7f,
0xb0, 0x0d, 0xa5, 0x86, 0xf0, 0x06, 0xa5, 0x83,
0x49, 0xff, 0x85, 0x83, 0x4c, 0x6c, 0x01, 0xa6,
0x7f, 0x9a, 0x4c, 0x2c, 0x00, 0x20, 0x44, 0x00,
0xa5, 0x80, 0x05, 0x81, 0xd0, 0x03, 0x4c, 0x5c,
0x01, 0xa5, 0x80, 0xd0, 0x03, 0x4c, 0x6c, 0x01,
0xa5, 0x81, 0xd0, 0x06, 0xa6, 0x7f, 0x9a, 0x4c,
0x2c, 0x00, 0xa5, 0x82, 0x45, 0x83, 0x30, 0x03,
0x4c, 0x97, 0x01, 0xa9, 0x00, 0x85, 0x86, 0x4c,
0xe6, 0x01, 0x20, 0x44, 0x00, 0xa5, 0x80, 0x05,
0x81, 0xd0, 0x03, 0x4c, 0x5c, 0x01, 0xa5, 0x80,
0xd0, 0x09, 0xa5, 0x83, 0x49, 0xff, 0x85, 0x83,
0x4c, 0x6c, 0x01, 0xa5, 0x81, 0xd0, 0x06, 0xa6,
0x7f, 0x9a, 0x4c, 0x2c, 0x00, 0xa5, 0x82, 0x45,
0x83, 0x10, 0x03, 0x4c, 0x97, 0x01, 0xa9, 0x01,
0x85, 0x86, 0x4c, 0xe6, 0x01, 0x20, 0x44, 0x00,
0xa5, 0x80, 0xf0, 0x04, 0xa5, 0x81, 0xd0, 0x03,
0x4c, 0x5c, 0x01, 0xa5, 0x82, 0x45, 0x83, 0x85,
0x83, 0xba, 0x86, 0x86, 0xa5, 0x80, 0x85, 0x89,
0xe6, 0x89, 0x18, 0x65, 0x81, 0x85, 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 0xd8, 0x60, 0x68, 0x85, 0x86, 0x68, 0x85,
0x87, 0x20, 0xc8, 0x04, 0xa2, 0x03, 0xb5, 0x88,
0x48, 0xca, 0x10, 0xfa, 0x48, 0xa5, 0x82, 0x48,
0x48, 0xa9, 0x03, 0x48, 0x4c, 0x2c, 0x00, 0xba,
0xe8, 0x86, 0x7d, 0xbc, 0x00, 0x01, 0x88, 0x98,
0x0a, 0x85, 0x81, 0x8a, 0x18, 0x65, 0x81, 0x69,
0x05, 0x85, 0x7c, 0xaa, 0xbd, 0x00, 0x01, 0x85,
0x87, 0xca, 0xbd, 0x00, 0x01, 0x85, 0x86, 0x20,
0xc8, 0x04, 0xba, 0x8a, 0x38, 0xe9, 0x06, 0xaa,
0x9a, 0xe8, 0xa5, 0x81, 0x18, 0x69, 0x04, 0x85,
0x85, 0xa4, 0x7d, 0xb9, 0x00, 0x01, 0x9d, 0x00,
0x01, 0xe8, 0xc8, 0xc6, 0x85, 0xd0, 0xf4, 0xa4,
0x7c, 0xa2, 0x03, 0xb5, 0x88, 0x99, 0x00, 0x01,
0x88, 0xca, 0x10, 0xf7, 0x88, 0xa5, 0x82, 0x99,
0x00, 0x01, 0x88, 0x88, 0xa9, 0x03, 0x99, 0x00,
0x01, 0x4c, 0x2c, 0x00, 0x68, 0x85, 0x80, 0xc6,
0x80, 0x68, 0x68, 0x85, 0x82, 0x68, 0xa5, 0x80,
0x38, 0xe9, 0x03, 0x90, 0x0e, 0xaa, 0x68, 0xd0,
0x6f, 0x68, 0xd0, 0x6c, 0xca, 0x10, 0xf7, 0xa9,
0x02, 0x85, 0x80, 0xa9, 0x00, 0x85, 0x88, 0xa5,
0x80, 0xc9, 0x01, 0xf0, 0x06, 0x68, 0xd0, 0x58,
0x68, 0x85, 0x88, 0x68, 0x85, 0x89, 0x68, 0x85,
0x8a, 0xa9, 0x0f, 0x85, 0x85, 0x46, 0x88, 0x66,
0x89, 0x66, 0x8a, 0x66, 0x87, 0x66, 0x86, 0xa2,
0x02, 0xb5, 0x88, 0x10, 0x03, 0x38, 0xe9, 0x30,
0xa8, 0x29, 0x08, 0xf0, 0x03, 0x88, 0x88, 0x88,
0x94, 0x88, 0xca, 0x10, 0xec, 0xc6, 0x85, 0xd0,
0xdc, 0xa5, 0x8a, 0xd0, 0x23, 0x46, 0x87, 0x66,
0x86, 0xa5, 0x82, 0x10, 0x12, 0xa5, 0x87, 0x49,
0xff, 0x85, 0x87, 0xa5, 0x86, 0x49, 0xff, 0x85,
0x86, 0xe6, 0x86, 0xd0, 0x02, 0xe6, 0x87, 0xa5,
0x87, 0x48, 0xa5, 0x86, 0x48, 0x4c, 0x2c, 0x00,
0x4c, 0x35, 0x00, 0x68, 0x85, 0x86, 0x68, 0x68,
0x85, 0x88, 0x68, 0x85, 0x89, 0x68, 0x85, 0x80,
0xc6, 0x80, 0x06, 0x80, 0x68, 0xa0, 0x00, 0x68,
0x10, 0x05, 0xa9, 0x2d, 0xc8, 0x91, 0x88, 0x68,
0x68, 0xd0, 0x04, 0xc6, 0x80, 0xd0, 0xf9, 0xc9,
0x10, 0xb0, 0x0c, 0x09, 0x30, 0xc8, 0x91, 0x88,
0xc6, 0x80, 0xf0, 0x19, 0x30, 0x17, 0x68, 0xaa,
0x4a, 0x4a, 0x4a, 0x4a, 0x09, 0x30, 0xc8, 0x91,
0x88, 0x8a, 0x29, 0x0f, 0x09, 0x30, 0xc8, 0x91,
0x88, 0xc6, 0x80, 0xd0, 0xe9, 0xc4, 0x86, 0x90,
0x05, 0xf0, 0x03, 0x4c, 0x3a, 0x00, 0x98, 0xa0,
0x00, 0x91, 0x88, 0x4c, 0x2c, 0x00, 0x00, 0x00,
0x56, 0x06, 0x53, 0x06, 0x4e, 0x06, 0x4e, 0x06,
0x4e, 0x06, 0x4e, 0x06, 0x4e, 0x06, 0x4e, 0x06,
0x4e, 0x06, 0x4e, 0x06, 0x4e, 0x06, 0x4e, 0x06,
0x4e, 0x06, 0xae, 0x05, 0xad, 0x05, 0xa0, 0x05,
0x98, 0x05, 0x97, 0x05, 0x92, 0x05, 0x59, 0x05,
0x4f, 0x05, 0x20, 0x05, 0xf7, 0x04, 0xaa, 0x04,
0x8f, 0x04, 0x4d, 0x04, 0x49, 0x04, 0x48, 0x04,
0x41, 0x04, 0x3c, 0x04, 0x34, 0x04, 0x2d, 0x04,
0x28, 0x04, 0x27, 0x04, 0x20, 0x04, 0x15, 0x04,
0x0d, 0x04, 0x06, 0x04, 0x01, 0x04, 0x00, 0x04,
0xf7, 0x03, 0xa4, 0x03, 0xa1, 0x03, 0x41, 0x03,
0xf4, 0x02, 0xef, 0x02, 0xd0, 0x02, 0x48, 0x02,
0x33, 0x02, 0xfc, 0x01, 0xba, 0x01, 0xa9, 0x01,
0x88, 0x01, 0x50, 0x01, 0xce, 0x00, 0xcd, 0x00,
0x7c, 0x00, 0x76, 0x00, 0x3a, 0x00, 0x00, 0x00,
0x00, 0x00, 0xda, 0x06};
struct
{
byte *Sig;
int SigLen;
void (*Proc)(word);
} Routines[]={ { IdSearchSig, sizeof(IdSearchSig), IdSearch},
{ TreeSearchSig, sizeof(TreeSearchSig), TreeSearch},
#ifdef TURTLEGRAPHICS
{ TurtleSig, sizeof(TurtleSig), TurtleGraphics},
#endif
{ RandomizeSig1, sizeof(RandomizeSig1), Randomize},
{ RandomizeSig2, sizeof(RandomizeSig2), Randomize},
{ RandomSig, sizeof(RandomSig), Random},
{ KeypressSig, sizeof(KeypressSig), Keypress},
{ LongIntSig, sizeof(LongIntSig), LongInt}
};
#define NUM_ROUTINES (sizeof(Routines)/sizeof(Routines[0]))
static inline word SelfRelPtr(word Addr)
{
#ifdef WORD_MEMORY
return(Addr-MemRd(Addr)/2);
#else
return(Addr-MemRd(Addr));
#endif
}
static inline word ProcBase(word JTab)
{
PointerCheck(JTab);
return (SelfRelPtr(WordIndexed(JTab,-1)));
}
void ProcessNative(word JTab)
{
word EntryPoint=ProcBase(JTab);
int i;
for (i=0; i<NUM_ROUTINES; i++)
{
int j;
for (j=0; j<Routines[i].SigLen; j++)
if (MemRdByte(EntryPoint,j)!=Routines[i].Sig[j])
goto next;
Routines[i].Proc(EntryPoint);
return;
next:
;
}
#ifdef XXX
TermClose();
for (i=0;WordIndexed(EntryPoint,i)<JTab; i++)
{
word w=MemRd(WordIndexed(EntryPoint,i));
printf(" 0x%02x, 0x%02x,", w&0xff, w>>8);
if ((i&3)==3)
printf("\n");
}
printf("\n");
panic("ProcessNative: unsupported native routine at 0x%04x", EntryPoint);
#else
XeqError(XNOTIMP);
#endif
}